package com.nwcl.common.conf;


import com.nwcl.common.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebMvcConfig implements  WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 加载拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String exculed[] = {
                "/registry/machine",//注册机器
                "/api/ysx/login",//悦私享小程序登录
                "/api/ysx/test",//悦私享小程序测试
                "/favicon.ico",//图标
                "/error",//错误页面
                "/*.txt"//不拦截txt文件
        };
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(exculed);
    }
}
